package com.just.dom4j;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

/**
 * 解析xml，saxReader可以解析本地xml文件或者url，不过url返回的信息要是标准的xml结构
 */
public class ParseXML {
    public static void main(String[] args){
        String path="D:\\ideaProjects\\dom4jdemo\\src\\main\\resources\\xml\\demo1.xml";
        Document document=parse(path);
        System.out.println(document.getRootElement().getName());
    }
    public static Document parse(String systemId){
        SAXReader saxReader=new SAXReader();
        Document document= null;
        try {
            document = saxReader.read(systemId);
        } catch (DocumentException e) {
            e.printStackTrace();
        }
        return document;
    }
}
